home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / webtp55.zip / WEAVE.CHG < prev    next >
Text File  |  1989-12-01  |  26KB  |  793 lines

  1. % This is WEAVE.CHG for TURBO Pascal 5.5
  2. % (c) 1989 by Peter Sawatzki
  3. %
  4. %  Change History:
  5. %
  6. %  Initials:   PS = Peter Sawatzki, FE617@DHAFEU11
  7. %  =========
  8. %
  9. %  rel.  date      Author  description
  10. %  ====  ====      ======  ===========
  11. %  v0.1  5-Mar-88  PS      initial TP3 release
  12. %  v0.2 29-Jul-89  PS      @i option: (nested) include files
  13. %
  14. %
  15. %  Tangle/Compile Instructions:
  16. %  ============================
  17. %  TANGLE WEAVE /d /m /c
  18. %  TPC /$A+,O-,E-,N-,B-,I-,V-,S-,D- /$M$5000,0,$2000 WEAVE
  19. %
  20. %
  21. ────────────────────────────────────────────────────────────────
  22. @x l.72 m.1
  23. @d banner=='This is WEAVE, Version 4'
  24. @y
  25. @d banner=='This is WEAVE, Version 4/TP55 0.2'
  26. @z
  27. ────────────────────────────────────────────────────────────────
  28. @x l.82 m.2
  29. @d end_of_WEAVE = 9999 {go here to wrap it up}
  30.  
  31. @p @t\4@>@<Compiler directives@>@/
  32. program WEAVE(@!web_file,@!change_file,@!tex_file);
  33. label end_of_WEAVE; {go here to finish}
  34. const @<Constants in the outer block@>@/
  35. type @<Types in the outer block@>@/
  36. var @<Globals in the outer block@>@/
  37. @y
  38. @p program WEAVE;
  39. const @<Constants in the outer block@>@/
  40. type @<Types in the outer block@>@/
  41. const @<Typed constants in the outer block@>@/
  42. var @<Globals in the outer block@>@/
  43. @<Inline procedures and functions@>@/
  44. @<All purpose procedures and functions@>@/
  45. @z
  46. ────────────────────────────────────────────────────────────────
  47. @x l.101 m.3
  48. @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
  49. @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
  50. @y
  51. @d ifdef(#)==@={$ifdef @>#@=}@>
  52. @d endif==@={$endif}@>
  53. @d debug==ifdef(deb)
  54. @d gubed==endif
  55. @d Asm(#)==inline(@[#@])
  56. @z
  57. ────────────────────────────────────────────────────────────────
  58. @x l.106 m.3
  59. @d stat==@{ {change this to `$\\{stat}\equiv\null$'
  60.   when gathering usage statistics}
  61. @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
  62.   when gathering usage statistics}
  63. @y
  64. @d stat==ifdef(sta)
  65. @d tats==endif
  66. @z
  67. ────────────────────────────────────────────────────────────────
  68. @x l.121 m.4
  69. @<Compiler directives@>=
  70. @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
  71. @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
  72. @y
  73. @<Inline proc...@>=
  74. function mavail: word;
  75. Asm(mov ah,$48/   {allocate memory}
  76.     mov bx,$FFFF/ {determine free memory}
  77.     int $21/
  78.     mov ax,bx);   {return size of largest available block}
  79.  
  80. function malloc (no: word): word;
  81. Asm(mov ah,$48/   {allocate memory}
  82.     pop bx/       {no of bytes}
  83.     int $21/
  84.     jnc ok/       {no error}
  85.     xor ax,ax/    {clear ax in case of error}
  86.  ok: );
  87.  
  88. procedure mfree (segm: word);
  89. Asm(mov ah,$49/ {free memory}
  90.     pop es/     {segment to free}
  91.     int $21);
  92. @z
  93. ────────────────────────────────────────────────────────────────
  94. @x l.146 m.6
  95. @d incr(#) == #:=#+1 {increase a variable by unity}
  96. @d decr(#) == #:=#-1 {decrease a variable by unity}
  97. @y
  98. @d incr(#) == Inc(#) {increase a variable by unity}
  99. @d decr(#) == Dec(#) {decrease a variable by unity}
  100. @d integer == LongInt
  101. @d void == begin end
  102. @z
  103. ────────────────────────────────────────────────────────────────
  104. @x l.172 m.7
  105. @d othercases == others: {default for cases not listed explicitly}
  106. @y
  107. @d othercases == else {default for cases not listed explicitly}
  108. @z
  109. ────────────────────────────────────────────────────────────────
  110. @x l.181 m.8
  111. @!max_bytes=45000; {|1/ww| times the number of bytes in identifiers,
  112.   index entries, and module names; must be less than 65536}
  113. @!max_names=5000; {number of identifiers, index entries, and module names;
  114.   must be less than 10240}
  115. @!max_modules=2000;{greater than the total number of modules}
  116. @!hash_size=353; {should be prime}
  117. @!buf_size=100; {maximum length of input line}
  118. @!longest_name=400; {module names shouldn't be longer than this}
  119. @!long_buf_size=500; {|buf_size+longest_name|}
  120. @!line_length=80; {lines of \TeX\ output have at most this many characters,
  121.   should be less than 256}
  122. @!max_refs=30000; {number of cross references; must be less than 65536}
  123. @!max_toks=30000; {number of symbols in \PASCAL\ texts being parsed;
  124.   must be less than 65536}
  125. @!max_texts=2000; {number of phrases in \PASCAL\ texts being parsed;
  126.   must be less than 10240}
  127. @!max_scraps=1000; {number of tokens in \PASCAL\ texts being parsed}
  128. @!stack_size=200; {number of simultaneous output levels}
  129. @y
  130. @!max_bytes=6400; {|1/ww| times the number of bytes in identifiers,
  131.   index entries, and module names; must be less than 65536}
  132. @!max_names=5000; {number of identifiers, index entries, and module names;
  133.   must be less than 10240}
  134. @!max_modules=2000;{greater than the total number of modules}
  135. @!hash_size=353; {should be prime}
  136. @!buf_size=100; {maximum length of input line}
  137. @!longest_name=400; {module names shouldn't be longer than this}
  138. @!long_buf_size=500; {|buf_size+longest_name|}
  139. @!line_length=80; {lines of \TeX\ output have at most this many characters,
  140.   should be less than 256}
  141. @!max_refs=32000; {number of cross references; must be less than 65536}
  142. @!max_toks=32000; {number of symbols in \PASCAL\ texts being parsed;
  143.   must be less than 65536}
  144. @!max_texts=3000; {number of phrases in \PASCAL\ texts being parsed;
  145.   must be less than 10240}
  146. @!max_scraps=3000; {number of tokens in \PASCAL\ texts being parsed}
  147. @!stack_size=300; {number of simultaneous output levels}
  148. @z
  149. ────────────────────────────────────────────────────────────────
  150. @x l.307 m.12
  151. @!text_file=packed file of text_char;
  152. @y
  153. @!text_file=Text;
  154. @z
  155. ────────────────────────────────────────────────────────────────
  156. @x l.309 m.13
  157. @ The \.{WEAVE} and \.{TANGLE} processors convert between ASCII code and
  158. the user's external character set by means of arrays |xord| and |xchr|
  159. that are analogous to \PASCAL's |ord| and |chr| functions.
  160.  
  161. @<Globals...@>=
  162. @!xord: array [text_char] of ASCII_code;
  163.   {specifies conversion of input characters}
  164. @!xchr: array [ASCII_code] of text_char;
  165.   {specifies conversion of output characters}
  166.  
  167. @ If we assume that every system using \.{WEB} is able to read and write the
  168. visible characters of standard ASCII (although not necessarily using the
  169. ASCII codes to represent them), the following assignment statements initialize
  170. most of the |xchr| array properly, without needing any system-dependent
  171. changes. For example, the statement \.{xchr[@@\'101]:=\'A\'} that appears
  172. in the present \.{WEB} file might be encoded in, say, {\mc EBCDIC} code
  173. on the external medium on which it resides, but \.{TANGLE} will convert from
  174. this external code to ASCII and back again. Therefore the assignment
  175. statement \.{XCHR[65]:=\'A\'} will appear in the corresponding \PASCAL\ file,
  176. and \PASCAL\ will compile this statement so that |xchr[65]| receives the
  177. character \.A in the external (|char|) code. Note that it would be quite
  178. incorrect to say \.{xchr[@@\'101]:="A"}, because |"A"| is a constant of
  179. type |integer|, not |char|, and because we have $|"A"|=65$ regardless of
  180. the external character set.
  181.  
  182. @<Set init...@>=
  183. xchr[@'40]:=' ';
  184. xchr[@'41]:='!';
  185. xchr[@'42]:='"';
  186. xchr[@'43]:='#';
  187. xchr[@'44]:='$';
  188. xchr[@'45]:='%';
  189. xchr[@'46]:='&';
  190. xchr[@'47]:='''';@/
  191. xchr[@'50]:='(';
  192. xchr[@'51]:=')';
  193. xchr[@'52]:='*';
  194. xchr[@'53]:='+';
  195. xchr[@'54]:=',';
  196. xchr[@'55]:='-';
  197. xchr[@'56]:='.';
  198. xchr[@'57]:='/';@/
  199. xchr[@'60]:='0';
  200. xchr[@'61]:='1';
  201. xchr[@'62]:='2';
  202. xchr[@'63]:='3';
  203. xchr[@'64]:='4';
  204. xchr[@'65]:='5';
  205. xchr[@'66]:='6';
  206. xchr[@'67]:='7';@/
  207. xchr[@'70]:='8';
  208. xchr[@'71]:='9';
  209. xchr[@'72]:=':';
  210. xchr[@'73]:=';';
  211. xchr[@'74]:='<';
  212. xchr[@'75]:='=';
  213. xchr[@'76]:='>';
  214. xchr[@'77]:='?';@/
  215. xchr[@'100]:='@@';
  216. xchr[@'101]:='A';
  217. xchr[@'102]:='B';
  218. xchr[@'103]:='C';
  219. xchr[@'104]:='D';
  220. xchr[@'105]:='E';
  221. xchr[@'106]:='F';
  222. xchr[@'107]:='G';@/
  223. xchr[@'110]:='H';
  224. xchr[@'111]:='I';
  225. xchr[@'112]:='J';
  226. xchr[@'113]:='K';
  227. xchr[@'114]:='L';
  228. xchr[@'115]:='M';
  229. xchr[@'116]:='N';
  230. xchr[@'117]:='O';@/
  231. xchr[@'120]:='P';
  232. xchr[@'121]:='Q';
  233. xchr[@'122]:='R';
  234. xchr[@'123]:='S';
  235. xchr[@'124]:='T';
  236. xchr[@'125]:='U';
  237. xchr[@'126]:='V';
  238. xchr[@'127]:='W';@/
  239. xchr[@'130]:='X';
  240. xchr[@'131]:='Y';
  241. xchr[@'1